<!DOCTYPE html>
<html>

<head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/index.css' />
    <script src="https://cdn.bootcss.com/socket.io/2.1.0/socket.io.js"></script>

    <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>

    <style>
        #example {
            display: flex;
            flex-direction: row;
            height: 400px;
            width: 1000px;
            border: 2px lightseagreen solid;

        }

        #example>div {
            display: flex;
            height: 100%;

        }

        .left {
            width: 200px;
            border-right: 1px red saddlebrown;
            flex-direction: column;


        }

        .left>div {
            display: flex;
            height: 30px;
            justify-content: flex-start;
            align-items: center;
            background-color: lightslategrey;
            /* margin-bottom: 1px white solid; */

        }

        .right {
            flex: 1;
            background-color: lightblue;

        }
    </style>

</head>

<body>
    <div class="layout" id="app">







    </div>

    <script>
        var socket = io.connect('http://localhost:3001');

        socket.on("abc", function (data) {
            console.log(data);

            socket.emit('chat message', "33333333333");

        })

        document.querySelector("#abc").addEventListener('click', function () {
            socket.emit('chat message', "444444");
        });
    </script>

    <script type="text/babel">
        const numbers = [1, 2, 3, 4, 5];


        var map={
            1:{
                msg_body:{
                    content:'1111111111'
                }
            },
            2:{
                msg_body:{
                    content:'2222222222'
                }
            },
            3:{
                msg_body:{
                    content:'33333'
                }
            },
            4:{
                msg_body:{
                    content:'44444'
                }
            }
        }


    class Clock extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                active_index:1
            };

            this.memberClick.bind(this);
        }
 
        memberClick(num){
                this.setState({
                    active_index:num
                })
        }

        render() {
            return (
                <div id="example">

                        <div class="left">
                            

                            {
                                numbers.map((num) =>
                                    <div onClick={()=>this.memberClick(num)}>{num}</div>
                                 )
                            }
                            
                            </div>
                        <div class="right">
                            {
                                map[this.state.active_index]&&map[this.state.active_index].msg_body.content
                            }
                            </div>


                </div>
            );
        }
    }

        ReactDOM.render(
         <Clock />   ,
            document.getElementById('app')
        );
    </script>

</body>

</html>